﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Poney_fight_club
{
    class Attack
    {
        //5. Poney et stéroïdes
        //Constructor here
        //constructeur de la classe Attack
        public Attack(string _name, int _min_damage, int _max_damage, int _critical_rate, int _critical_fail_rate)
        {
            r = new Random();
            name = _name;
            min_damage = _min_damage;
            max_damage = _max_damage;
            if (critical_rate >= 0 && critical_rate <= 10 )
                critical_rate = _critical_rate;
            if (critical_fail_rate >= 0 && critical_fail_rate <= 10)
                critical_fail_rate = _critical_fail_rate;
        }
        //5. Poney et stéroïdes
        //Attributes, getters and setters for name, min_damage, max_damage, critical_rate, critical_fail_rate here
        //Attributs de la classe Attack
        string name;
        int min_damage, max_damage, critical_rate, critical_fail_rate;
        Random r;
        //Accesseur de la classe Attack
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public int Min_damage
        {
            get { return min_damage; }
            set { min_damage = value; }
        }

        public int Max_damage
        {
            get { return max_damage; }
            set { max_damage = value; }
        }

        public int Critical_rate
        {
            get { return critical_rate; }
            set { critical_rate = value; }
        }

        public int Critical_fail_rate
        {
            get { return critical_fail_rate; }
            set { critical_fail_rate = value; }
        }

        //5. Poney et stéroïdes
        //Method Damage() here
        //Methode de calcul des dommages
        public int Damage()
        {
            int damage;
            int fail = r.Next(100);
            int critical = r.Next(100);

            if (fail <= critical_fail_rate)
                damage = min_damage;
            else if (critical <= critical_rate)
                damage = max_damage;
            else
                damage = r.Next(min_damage, max_damage);

            return damage;
        }
    }
}
